import CommonHeader from '@/components/common-header/index'
import CommonInfo from '../components/CommonInfo/index'
import ApprovalButton from '../components/Button/index'
import Textarea from '../components/Textarea/index'
import DateSelect from '../components/DateSelect/index'
import Field from '../components/Field/index'

export default {
  name: 'TravelApproval',
  components: {
    CommonHeader,
    CommonInfo,
    ApprovalButton,
    Textarea,
    DateSelect,
    Field,
  },
  data() {
    return {
      warn: '您有未填写的数据',
      approval: {
        address: '',
        travelTools: '',
        startTime: '',
        endTime: '',
        travelReason: '',
      },
    }
  },
  methods: {
    getAddress(data) {
      this.approval.address = data
    },
    getTravelTools(data) {
      this.approval.travelTools = data
    },
    getStartTime(data) {
      this.approval.startTime = data
    },
    getEndTime(data) {
      this.approval.endTime = data
    },
    getTravelReason(data) {
      this.approval.travelReason = data.mp.detail.__args__[0]
    },
  },
  watch: {
    approval: {
      deep: true,
      handler: function(newV, oldV) {
        for (let key in newV) {
          if (!newV[key]) {
            return
          }
        }
        this.warn = ''
      },
    },
  },
}
